#include<iostream>
#include<memory>
#include<tuple>
using namespace std;
/*  2022.08.03
描述: 指针指针管理单例模式生命周期；
使用私有化析构来隐藏delete方式显式析构
使用tunple 来返回多个值
 */
class Test{
    int m_num=0;
    string m_Name;
    static shared_ptr<Test> m_Instance;
    Test(){
        cout<<"构造对象"<<endl;
    }
    ~Test(){
        cout<<"析构函数"<<endl;
    }
    public:
    static shared_ptr<Test> getInstance(){
        if(nullptr==m_Instance){
            m_Instance = shared_ptr<Test>(new Test(),[](Test *p){p->destory();});
        }
        return m_Instance;
    }
    void setter(int val,const string&s){
        m_num =val;
        m_Name =s;
    }
    tuple<int,string> getter(){
        return{m_num,m_Name};
    }
    void destory(){
        delete this;
    }
    Test(const Test& rhs)=delete;
    Test& operator=(const Test&)=delete;

};
shared_ptr<Test> Test::m_Instance=nullptr;
void show(shared_ptr<Test> st){
    auto ans=st->getter();
    cout<<"品牌"<<get<0>(ans)<<get<1>(ans)<<endl;
}
int main(){
   auto inst = Test::getInstance();
   inst->setter(1,"小米");
   show(inst);
}